#!/bin/bash
# author : Jalright
# date : 2021-01-27

yum -y install xz tar gcc make tk-devel wget sqlite-devel zlib-devel  readline-devel openssl-devel curl-devel tk-devel gdbm-devel xz-devel bzip2-devel libffi-devel

cd /root/

wget -c https://mirrors.huaweicloud.com/python/3.9.1/Python-3.9.1.tgz

tar xvf Python-3.9.1.tar.xz

cd Python-3.9.1

./configure --prefix=/opt/python391

make

make install

echo 'export PATH=/opt/python391/bin:$PATH' >>/etc/profile

mkdir -p ~/.pip

# 判断文件是否存在，存在就进行备份
if [ -f ~/.pip/pip.conf ]
then
    mv -f ~/.pip/pip.conf  ~/.pip/pip.conf_bak
fi
# 设置镜像
cat > ~/.pip/pip.conf <<EOF
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com
EOF

source /etc/profile

python3 -V
